package com.dnxh.controller;


import com.dnxh.constant.CustomResult;
import com.dnxh.entity.request.CreateMeetingRequest;
import com.dnxh.entity.request.SearchAdminRequest;
import com.dnxh.service.MeetingService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zhiqiu
 * @since 2022 -04-12
 */
@RestController
@RequestMapping("/meeting")
public class MeetingController {

	@Resource
	private MeetingService metingService;
	
	/**
	 * 创建一个会议/比赛
	 *
	 * @param request the request
	 * @return the custom result
	 */
	@PostMapping("/create")
	public CustomResult create(@RequestBody@Valid CreateMeetingRequest request){
		return metingService.create(request);
	}
	
	/**
	 * Search custom result.
	 *
	 * @param request the request
	 * @return the custom result
	 */
	@PostMapping("/search")
	public CustomResult search(@RequestBody@Valid SearchAdminRequest request){
		return metingService.search(request);
	}
	
	/**
	 * 删除会议
	 *
	 * @param id the id
	 * @return the custom result
	 */
	@DeleteMapping("/{id}")
	public CustomResult delete(@PathVariable("id") Long id){
		return metingService.delete(id);
	}
	
	/**
	 * 查询会议/比赛名字
	 *
	 * @param id the id
	 * @return the custom result
	 */
	@GetMapping("/{id}")
	public CustomResult searchMeetingName(@PathVariable("id") Long id){
		return metingService.searchMeetingName(id);
	}
}